// 基于template/src/widgets/\{{appEntities}}/\{{ctrls@LIST}}-list/\{{ctrls@LIST}}-list-model.ts.hbs生成
import { IListModel } from "@/core";

//  获取列表模型
function getModel(): IListModel {
    return {
        cssName: "{{#if ctrl.psSysCss}}{{ctrl.psSysCss.cssName}}{{/if}}",             
		aggMode: '{{ctrl.aggMode}}',
		caption: '{{ctrl.caption}}',
		controlType: '{{ctrl.controlType}}',
		codeName: '{{ctrl.codeName}}',
		entityCodeName: '{{ctrl.psAppDataEntity.codeName}}',
		entityLogicName: '{{ctrl.psAppDataEntity.logicName}}',
{{#and ctrl.enableGroup (neq ctrl.groupMode 'NONE')}}
		enableGroup: true,
		//  请确保此项与表格分组列模型中的dataIndex一致
		groupDataIndex: 'grid_group',
		groupMode: '{{ctrl.groupMode}}',
		groupField: '{{lowerCase ctrl.groupPSAppDEField.codeName}}',
	{{#if ctrl.psDEListDataItems}}
		{{#each ctrl.psDEListDataItems as | listItem |}}
			{{#and listItem.psAppDEField (eq listItem.psAppDEField.codeName ctrl.groupPSAppDEField.codeName) listItem.frontPSCodeList}}
		groupFieldCodeListTag: '{{listItem.frontPSCodeList.codeListTag}}',
			{{/and}}
		{{/each}}
	{{/if}}
    {{#eq ctrl.groupMode 'CODELIST'}}
      	groupCodeListTag: '{{ctrl.groupPSCodeList.codeListTag}}',
    {{/eq}}
{{/and}}
		name: '{{ctrl.name}}',
		noSort: {{ctrl.noSort}},
		showHeader: {{#if ctrl.hideHeader}}false{{else}}true{{/if}},
		sortDir: '{{ctrl.minorSortDir}}',
		sortField: '{{#if ctrl.minorSortPSAppDEField}}{{lowerCase ctrl.minorSortPSAppDEField.codeName}}{{/if}}',
		limit: {{#if ctrl.pagingSize}}{{ctrl.pagingSize}}{{else}}20{{/if}},
{{#if ctrl.psDEDataImport}}
		dataImport: {
            codeName: '{{ctrl.psDEDataImport.codeName}}',
            ignoreError: {{ctrl.psDEDataImport.ignoreError}},
		},
{{/if}}
		paging: {
			defaultPageSize: {{#if ctrl.pagingSize}}{{ctrl.pagingSize}}{{else}}20{{/if}}
		},
{{#if ctrl.psDEListItems}}
    {{#each ctrl.psDEListItems as | listItem |}}
        {{#if (and (eq listItem.itemType 'ACTIONITEM') listItem.psDEUIActionGroup)}}
        uIActionGroup: {
            {{#each listItem.psDEUIActionGroup.psUIActionGroupDetails as | uiAction |}}
            "{{uiAction.psUIAction.uIActionTag}}": {
                caption: "{{uiAction.psUIAction.caption}}",
                uIActionMode: "{{uiAction.psUIAction.uIActionMode}}",
                disabled: false,
                visible: true,
                actionTag: "{{uiAction.psUIAction.uIActionTag}}",
                noPrivDisplayMode: {{uiAction.psUIAction.noPrivDisplayMode}},
                dataAccessAction: "{{uiAction.psUIAction.dataAccessAction}}",
                actionTarget: "{{uiAction.psUIAction.actionTarget}}",
                showCaption: {{uiAction.showCaption}},
                showIcon: {{uiAction.showIcon}},
                predefinedType: "{{uiAction.psUIAction.predefinedType}}",
                actionDECodeName: "{{#if uiAction.psUIAction.psAppDataEntity}}{{uiAction.psUIAction.psAppDataEntity.codeName}}{{/if}}",
                {{#if uiAction.psUIAction.psSysImage}}{{#if uiAction.psUIAction.psSysImage.imagePath}}imgPath: "{{uiAction.psUIAction.psSysImage.imagePath}}",{{/if}}
                {{#if uiAction.psUIAction.psSysImage.cssClass}}iconClass: "{{uiAction.psUIAction.psSysImage.cssClass}}"{{/if}}{{/if}}
            }{{#unless @last}},{{/unless}}
            {{/each}}
        }
        {{/if}}
    {{/each}}
{{/if}}
    };
}

export const model = getModel();